/*******************************************************************************
 * Copyright (c) Jerges A. Bello G. 2014. Reservado todos los derechos.
 ******************************************************************************/
package com.jabex.persistence.model;

import com.jabex.common.to.ImagesTO;
import org.joda.time.LocalTime;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.Table;
import java.util.Date;

/**
 * Created by jaugusto on 27/05/14.
 */
@Entity
@Table(name = "ADA_IMAGES")
public class Images extends Identity {
	@Column(name = "NAME", unique = false, nullable = false)
	private String name;
	@Column(name = "DESCRIPTION", unique = false, nullable = true)
	private String description;
	@Column(name = "CREATE_DATE", unique = false, nullable = false)
	private Date createDate;
	@Column(name = "ACTIVE", unique = false, nullable = false)
	private Boolean isActive;
	@Column(name = "URL_IMAGE", unique = false, nullable = true)
	private String urlImage;
	@Column(name = "TYPE_IMAGE", unique = false, nullable = false)
	private String typeImage;
	@Lob
	@Column(name = "IMG_BYTE", unique = false, nullable = true)
	private byte[] imgByte;

	public Images(ImagesTO imagesTO) {
		this.name = imagesTO.getName();
		this.description = imagesTO.getDescription();
		if (imagesTO.getCreateTime() != null) {
			this.createDate.setTime(imagesTO.getCreateTime().toDateTime().getMillis());
		} else {
			this.createDate.setTime(imagesTO.getCreateDate().toDateTime(LocalTime.now()).getMillis());
		}
		this.isActive = imagesTO.getIsActive();
		this.urlImage = imagesTO.getUrlImage();
		this.typeImage = imagesTO.getTypeImage();
		this.imgByte = imagesTO.getImgByte();
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}


	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}


	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public Boolean getIsActive() {
		return isActive;
	}

	public void setIsActive(Boolean isActive) {
		this.isActive = isActive;
	}


	public String getUrlImage() {
		return urlImage;
	}

	public void setUrlImage(String urlImage) {
		this.urlImage = urlImage;
	}


	public String getTypeImage() {
		return typeImage;
	}

	public void setTypeImage(String typeImage) {
		this.typeImage = typeImage;
	}


	public byte[] getImgByte() {
		return imgByte;
	}

	public void setImgByte(byte[] imgByte) {
		this.imgByte = imgByte;
	}
}
